package com.ruoyi.web.controller.retirement;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.retirement.domain.RetirementClassifyTwo;
import com.ruoyi.retirement.service.IRetirementClassifyTwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 文章二级分类Controller
 * 
 * @author 曹旭
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/retirement/retirementClassTwo")
public class RetirementClassifyTwoController extends BaseController
{
    @Autowired
    private IRetirementClassifyTwoService retirementClassifyTwoService;


    /**
     * 查询文章二级分类列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:list')")
    @GetMapping("/page")
    public TableDataInfo page(RetirementClassifyTwo retirementClassifyTwo)
    {
        startPage();
        List<RetirementClassifyTwo> list = retirementClassifyTwoService.selectRetirementClassifyTwoList(retirementClassifyTwo);
        return getDataTable(list);
    }

    /**
     * 查询文章二级分类列表
     */
    @GetMapping("/list")
    public AjaxResult list(RetirementClassifyTwo retirementClassifyTwo)
    {
        List<RetirementClassifyTwo> list = retirementClassifyTwoService.selectRetirementClassifyTwoList(retirementClassifyTwo);
        return success(list);
    }


    /**
     * 导出文章二级分类列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:export')")
    @Log(title = "文章二级分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RetirementClassifyTwo retirementClassifyTwo)
    {
        List<RetirementClassifyTwo> list = retirementClassifyTwoService.selectRetirementClassifyTwoList(retirementClassifyTwo);
        ExcelUtil<RetirementClassifyTwo> util = new ExcelUtil<RetirementClassifyTwo>(RetirementClassifyTwo.class);
        util.exportExcel(response, list, "文章二级分类数据");
    }

    /**
     * 获取文章二级分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(retirementClassifyTwoService.selectRetirementClassifyTwoById(id));
    }

    /**
     * 新增文章二级分类
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:add')")
    @Log(title = "文章二级分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RetirementClassifyTwo retirementClassifyTwo)
    {
        return toAjax(retirementClassifyTwoService.insertRetirementClassifyTwo(retirementClassifyTwo));
    }

    /**
     * 修改文章二级分类
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:edit')")
    @Log(title = "文章二级分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RetirementClassifyTwo retirementClassifyTwo)
    {
        return toAjax(retirementClassifyTwoService.updateRetirementClassifyTwo(retirementClassifyTwo));
    }

    /**
     * 删除文章二级分类
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementClassTwo:remove')")
    @Log(title = "文章二级分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(retirementClassifyTwoService.deleteRetirementClassifyTwoByIds(ids));
    }
}
